From: Brian Wolff Date: Wed, 17 Aug 2011 00:46:58 +0000 (+0000) Subject: Follow-up r94680 - fix unit tests. X-Git-Tag: 1.31.0-rc.0~28216 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=c9097200314fe553d1dc7349360c4c6c3628410a;p=lhc%2Fweb%2Fwiklou.git Follow-up r94680 - fix unit tests. The way the magic variable unit tests are run looks a little sketchy to me... --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index fdce7fa2b0..dc039fd40e 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2660,6 +2660,15 @@ class Parser { global $wgContLang, $wgSitename, $wgServer; global $wgArticlePath, $wgScriptPath, $wgStylePath; + if ( is_null( $this->mTitle ) ) { + // If no title set, bad things are going to happen + // later. Title should always be set since this + // should only be called in the middle of a parse + // operation (but the unit-tests do funky stuff) + throw new MWException( __METHOD__ . ' Should only be ' + . ' called while parsing (no title set)' ); + } + /** * Some of these require message or data lookups and can be * expensive to check many times. diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 3c8430952e..f70c764a03 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -38,6 +38,8 @@ class MagicVariableTest extends MediaWikiTestCase { # initialize parser output $this->testParser->clearState(); + # Needs a title to do magic word stuff + $this->testParser->setTitle( Title::newFromText( 'Tests' ) ); } /** destroy parser (TODO: is it really neded?)*/